#include "StdAfx.h"
#include "CircuitRoundRect.h"


CCircuitRoundRect::CCircuitRoundRect(void)
{
	m_dblStartPosX = 0.0;
	m_dblStartPosY = 0.0;
	m_dblEndPosX = 0.0;
	m_dblEndPosY = 0.0;
	m_dblRadiusX = 0.0;
	m_dblRadiusY = 0.0;
	m_dblBorderWidth = 0.0;
	m_dblBorderColor[0] = 0.0;
	m_dblBorderColor[1] = 0.0;
	m_dblBorderColor[2] = 0.0;
	m_dblFillColor[0] = 0.0;
	m_dblFillColor[1] = 0.0;
	m_dblFillColor[2] = 0.0;
	m_bSelected = false;
	m_bIsFill = false;
}

CCircuitRoundRect::CCircuitRoundRect(const CCircuitRoundRect *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblStartPosX = pEntityObj->GetStartPosX();
	m_dblStartPosY = pEntityObj->GetStartPosY();
	m_dblEndPosX = pEntityObj->GetEndPosX();
	m_dblEndPosY = pEntityObj->GetEndPosY();
	m_dblRadiusX = pEntityObj->GetRadiusX();
	m_dblRadiusY = pEntityObj->GetRadiusY();
	m_dblBorderWidth = pEntityObj->GetBorderWidth();
	m_dblBorderColor[0] = pEntityObj->GetBorderColorR();
	m_dblBorderColor[1] = pEntityObj->GetBorderColorG();
	m_dblBorderColor[2] = pEntityObj->GetBorderColorB();
	m_dblFillColor[0] = pEntityObj->GetFillColorR();
	m_dblFillColor[1] = pEntityObj->GetFillColorG();
	m_dblFillColor[2] = pEntityObj->GetFillColorB();
	m_bSelected = pEntityObj->IsSelect();
	m_bIsFill = pEntityObj->IsFill();
}

CCircuitRoundRect::CCircuitRoundRect(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblStartPosX = 0.0;
	m_dblStartPosY = 0.0;
	m_dblEndPosX = 0.0;
	m_dblEndPosY = 0.0;
	m_dblRadiusX = 0.0;
	m_dblRadiusY = 0.0;
	m_dblBorderWidth = 0.0;
	m_dblBorderColor[0] = 0.0;
	m_dblBorderColor[1] = 0.0;
	m_dblBorderColor[2] = 0.0;
	m_dblFillColor[0] = 0.0;
	m_dblFillColor[1] = 0.0;
	m_dblFillColor[2] = 0.0;
	m_bSelected = false;
	m_bIsFill = false;
}

CCircuitRoundRect::~CCircuitRoundRect(void)
{
	Clear();
}

void CCircuitRoundRect::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblStartPosX;
		ar << m_dblStartPosY;
		ar << m_dblEndPosX;
		ar << m_dblEndPosY;
		ar << m_dblRadiusX;
		ar << m_dblRadiusY;
		ar << m_dblBorderWidth;
		ar << m_dblBorderColor[0];
		ar << m_dblBorderColor[1];
		ar << m_dblBorderColor[2];
		ar << m_dblFillColor[0];
		ar << m_dblFillColor[1];
		ar << m_dblFillColor[2];
		ar << m_bSelected ;
		ar << m_bIsFill;
	}
	else
	{
		ar >> m_dblStartPosX;
		ar >> m_dblStartPosY;
		ar >> m_dblEndPosX;
		ar >> m_dblEndPosY;
		ar >> m_dblRadiusX;
		ar >> m_dblRadiusY;
		ar >> m_dblBorderWidth;
		ar >> m_dblBorderColor[0];
		ar >> m_dblBorderColor[1];
		ar >> m_dblBorderColor[2];
		ar >> m_dblFillColor[0];
		ar >> m_dblFillColor[1];
		ar >> m_dblFillColor[2];
		ar >> m_bSelected ;
		ar >> m_bIsFill;
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitRoundRect::Clone() const
{
	return new CCircuitRoundRect(this);
}

void CCircuitRoundRect::Transform(const CMatrix transf)
{

}

bool CCircuitRoundRect::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitRoundRect::Clear()
{

}

void CCircuitRoundRect::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitRoundRect::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitRoundRect::CreateDisplayObj(long lLayerId)
{
	CCircuitRoundRectDisObj *pRonudRectDis = new CCircuitRoundRectDisObj(this);
	pRonudRectDis->SetLayerId(lLayerId);
	return pRonudRectDis;
}

void CCircuitRoundRect::CalcBox()
{
	m_minX = m_dblStartPosX;
	m_minY = m_dblStartPosY;
	m_maxX = m_dblEndPosX;
	m_maxY = m_dblEndPosY;
}

eCircuitUnitEntType CCircuitRoundRect::GetUnitType() const
{
	return CIRCUIT_ROUNDRECT;
}

double CCircuitRoundRect::GetStartPosX() const
{
	return m_dblStartPosX;
}

double CCircuitRoundRect::GetStartPosY() const
{
	return m_dblStartPosY;
}

double CCircuitRoundRect::GetEndPosX() const
{
	return m_dblEndPosX;
}

double CCircuitRoundRect::GetEndPosY() const
{
	return m_dblEndPosY;
}

double CCircuitRoundRect::GetBorderWidth() const
{
	return m_dblBorderWidth;
}

double CCircuitRoundRect::GetBorderColorR() const
{
	return m_dblBorderColor[0];
}

double CCircuitRoundRect::GetBorderColorG() const
{
	return m_dblBorderColor[1];
}

double CCircuitRoundRect::GetBorderColorB() const
{
	return m_dblBorderColor[2];
}

double CCircuitRoundRect::GetRadiusX() const
{
	return m_dblRadiusX;
}

double CCircuitRoundRect::GetRadiusY() const
{
	return m_dblRadiusY;
}

bool CCircuitRoundRect::IsSelect() const
{
	return m_bSelected;
}

bool CCircuitRoundRect::IsFill() const
{
	return m_bIsFill;
}

double CCircuitRoundRect::GetFillColorR() const
{
	return m_dblFillColor[0];
}

double CCircuitRoundRect::GetFillColorG() const
{
	return m_dblFillColor[1];
}

double CCircuitRoundRect::GetFillColorB() const
{
	return m_dblFillColor[2];
}

void CCircuitRoundRect::SetStartPosX(double posX)
{
	m_dblStartPosX = posX;
}

void CCircuitRoundRect::SetStartPosY(double posY)
{
	m_dblStartPosY = posY;
}

void CCircuitRoundRect::SetEndPosX(double posX) 
{
	m_dblEndPosX = posX;
}

void CCircuitRoundRect::SetEndPosY(double posY)
{
	m_dblEndPosY = posY;
}

void CCircuitRoundRect::SetBorderWidth(double dblWidth)
{
	m_dblBorderWidth = dblWidth;
}

void CCircuitRoundRect::SetBorderColorR(double colR)
{
	m_dblBorderColor[0] = colR;
}

void CCircuitRoundRect::SetBorderColorG(double colG)
{
	m_dblBorderColor[1] = colG;
}

void CCircuitRoundRect::SetBorderColorB(double colB)
{
	m_dblBorderColor[2] = colB;
}

void CCircuitRoundRect::SetRadiusX(double rad)
{
	m_dblRadiusX = rad;
}

void CCircuitRoundRect::SetRadiusY(double rad)
{
	m_dblRadiusY = rad;
}

void CCircuitRoundRect::SetSelect(bool bFlag)
{
	m_bSelected = bFlag;
}

void CCircuitRoundRect::SetFill(bool bFlag)
{
	m_bIsFill = bFlag;
}

void CCircuitRoundRect::SetFillColorR(double colR)
{
	m_dblFillColor[0] = colR;
}

void CCircuitRoundRect::SetFillColorG(double colG)
{
	m_dblFillColor[1] = colG;
}

void CCircuitRoundRect::SetFillColorB(double colB)
{
	m_dblFillColor[2] = colB;
}